/**
 * Copyright (C) 2013 phloc systems
 * http://www.phloc.com
 * office[at]phloc[dot]com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.phloc.schematron.pure.bound.xpath;

import java.util.List;
import java.util.Map;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
import javax.xml.xpath.XPathExpression;

import com.phloc.commons.collections.ContainerHelper;
import com.phloc.schematron.pure.model.PSAssertReport;

/**
 * This class represents a single XPath-bound assert- or report-element.
 * 
 * @author philip
 */
@Immutable
public final class PSXPathBoundAssertReport
{
  private final PSAssertReport m_aAssertReport;
  private final XPathExpression m_aTestExpression;
  private final List <PSXPathBoundElement> m_aElements;
  private final Map <String, PSXPathBoundDiagnostic> m_aBoundDiagnostics;

  PSXPathBoundAssertReport (@Nonnull final PSAssertReport aAssertReport,
                            @Nonnull final XPathExpression aTestExpression,
                            @Nonnull final List <PSXPathBoundElement> aElements,
                            @Nonnull final Map <String, PSXPathBoundDiagnostic> aBoundDiagnostics)
  {
    if (aAssertReport == null)
      throw new NullPointerException ("AssertReport");
    if (aTestExpression == null)
      throw new NullPointerException ("TestExpression");
    if (aElements == null)
      throw new NullPointerException ("Elements");
    if (aBoundDiagnostics == null)
      throw new NullPointerException ("BoundDiagnostics");
    m_aAssertReport = aAssertReport;
    m_aTestExpression = aTestExpression;
    m_aElements = aElements;
    m_aBoundDiagnostics = aBoundDiagnostics;
  }

  @Nonnull
  public PSAssertReport getAssertReport ()
  {
    return m_aAssertReport;
  }

  @Nonnull
  public XPathExpression getTestExpression ()
  {
    return m_aTestExpression;
  }

  @Nonnull
  public List <PSXPathBoundElement> getAllContentElements ()
  {
    return ContainerHelper.newList (m_aElements);
  }

  @Nullable
  public PSXPathBoundDiagnostic getDiagnosticOfID (@Nullable final String sID)
  {
    return m_aBoundDiagnostics.get (sID);
  }
}
